
#ifndef JSON_CLASS_GENERATOR_HXX
#define JSON_CLASS_GENERATOR_HXX


#include "Generator.h"
#include "JsonNode.h"
#include "contrib/CJsonObject.hpp"

namespace codegen
{
    class JsonClassGenerator : public Generator
    {
    public:
        JsonClassGenerator(neb::CJsonObject* json,
            const resip::Data& class_name,
            const resip::Data& base_class = resip::Data::Empty);
        ~JsonClassGenerator();

    protected:
        bool parse();
        bool parse_recursive(Node* parent, neb::CJsonObject& obj);

        EncodeStream& encode_header(EncodeStream& ostm) const;
        EncodeStream& encode_class(EncodeStream& ostm) const;
        EncodeStream& encode_footer(EncodeStream& ostm) const;

        Node* create_array_node(const neb::CJsonObject& obj, int index, Node* parent);
        Node* create_non_array_node(const neb::CJsonObject& obj, const std::string& key, Node* parent);

        Node* new_node(Node::Type type, const resip::Data& key, const resip::Data& val, Node* parent);

        neb::CJsonObject*   json_;
        JsonNodeRoot*       root_;
    };
}

#endif // #ifndef JSON_CLASS_GENERATOR_HXX
